package com.example.aopproxy.component;

import com.example.aopproxy.demo.StudentDo;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class HomeAspect {

    @Autowired
    private Student student;

    /**
     * 切点：配置拦截规则
     */
    @Pointcut("execution(* com.example.aopproxy.controller.UserController.home())")
    public void pointcut() {
    }

    /**
     * 前置通知
     */
    @Before("pointcut()")
    public void beforeAdvice() {
        student.readHomeWork();
    }

    /**
     * 后置通知
     */
    @After("pointcut()")
    public void aftereAdvice() {
        student.completeHomeWork();
    }


}
